
const defaultConfig= require('../../config/config.default')


//鉴权中间件
const authRole = function(){
    return async(ctx,next)=>{
        // 打印元地址
        console.log(ctx.originalUrl,'ctx0');
        // console.log(defaultConfig.whitelist.includes( ctx.originalUrl),'ctx')
        if(!defaultConfig.whitelist.includes( ctx.originalUrl)){
            if(ctx.request.header.Authorization){
                await next()
            }else {
                ctx.body={
                    code:401,
                    msg:'未携带token,请重新登录'
                }
                return
            }
        }else {
            
        }
        
    }
}

module.exports=authRole